import {
  IsInt,
  IsBoolean,
  IsDate,
  Length
} from "class-validator";

import { Column, Entity, ManyToOne, OneToOne, PrimaryColumn, JoinColumn } from "typeorm";
import { Power } from "@src/apps/goods/entities/power.entity"
import { Bec } from "@src/apps/goods/entities/bec.entity"


export const MAX_IP_LENGTH = 64;
export const MAX_STACK_LENGTH = 6;
export const MAX_MAC_LENGTH = 48;
@Entity("good_good")
export class Good {
  @PrimaryColumn("int")
  @IsInt()
  id: number;

  @Column("int")
  @IsInt()
  runNo: number;

  @Column("varchar", { length: MAX_MAC_LENGTH })
  @Length(7,MAX_MAC_LENGTH)
  mac: string;
  
  @Column("varchar", { length: MAX_IP_LENGTH })
  @Length(7,MAX_IP_LENGTH)
  ip: string;

  @Column("varchar", { length: MAX_STACK_LENGTH })
  @Length(1,MAX_STACK_LENGTH)
  stack: string
  
  @Column("int")
  channel: number;

  @ManyToOne(()=>Power, power=>power.gcus)
  power: Power;

  @ManyToOne(()=>Bec, bec=>bec.gcus)
  bec: Bec;
}